using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using FireStarter.Base;
using FireStarterModeller.BO;
using FireStarterModeller.Logic;
using Habanero.Base;
using Habanero.Base.Exceptions;
using Habanero.BO;
using Habanero.BO.ClassDefinition;
using Habanero.BO.Loaders;
using Habanero.Util;
using NUnit.Framework;
using Rhino.Mocks;

namespace FireStarterModeller.Test.BO
{
    /// <summary>
    /// Provides a place to write custom tests for DMProperty objects.
    /// This file is only written once and can be changed.  The Def file
    /// attached to this as a dependent is rewritten with each regeneration
    /// and contains the standard tests for DMProperty.
    /// Regenerate this test project whenever there have been changes to the
    /// business objects.
    /// If tests are failing due to a unique setup in your application,
    /// you can either override the Create methods in TestUtils, or you
    /// can add the test to the ignore list below and reimplement it here.
    /// </summary>
    public partial class TestDMProperty
    {
        [TestFixtureSetUp]
        public void SetupTestFixture()
        {
            //------------------------------------------------------------
            // Use this list to ignore generated tests that are failing
            // due to a unique condition in your application.
            // Remember to reimplement the test here.
            //------------------------------------------------------------
            //_ignoreList.Add("TestMethodName", "Reason for ignoring it");
            base.SetupFixture();
        }

        [Test]
        public void Test_ToString()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            //---------------Assert Precondition----------------
            TestUtilsShared.AssertStringNotEmpty(dmProperty.PropertyName, "dmProperty.PropertyName");
            Assert.IsNotNull(dmProperty.Class);
            //---------------Execute Test ----------------------
            string actualToString = dmProperty.ToString();
            //---------------Test Result -----------------------
            //Assert.AreEqual(dmProperty.Class.ClassNameBO + " - " + dmProperty.PropertyName, actualToString);
            Assert.AreEqual(dmProperty.PropertyName, actualToString);
        }

        [Test]
        public void Test_HasLookuplist_False_NoLookupList()
        {
            //---------------Set up test pack-------------------
            DMProperty property = TestUtilsDMProperty.CreateUnsavedDefaultDMProperty();
            TestUtilsDMProperty.SetDMPropWithLookupList(property);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(property.LookupList);
            //---------------Execute Test ----------------------
            bool hasLookupList = property.HasLookupList;
            //---------------Test Result -----------------------
            Assert.IsTrue(hasLookupList);
        }

        [Test]
        public void Test_HasLookuplist_True_NonNullLookupList()
        {
            //---------------Set up test pack-------------------
            DMProperty property = TestUtilsDMProperty.CreateUnsavedDefaultDMProperty();
            //---------------Assert Precondition----------------
            Assert.IsNull(property.LookupList);
            //---------------Execute Test ----------------------
            bool hasLookupList = property.HasLookupList;
            //---------------Test Result -----------------------
            Assert.IsFalse(hasLookupList);
        }

        [Test]
        public void Test_ToString_PropNameIsNull()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty_WithClassNull();
            dmProperty.PropertyName = null;
            //---------------Assert Precondition----------------
            Assert.IsNull(dmProperty.PropertyName);
            //---------------Execute Test ----------------------
            string actualToString = dmProperty.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual(dmProperty.PropertyID.ToString(), actualToString);
        }

        [Test]
        public void Test_ToString_ClassIsNull()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty_WithClassNull();
            dmProperty.Class = null;
            //---------------Assert Precondition----------------
            Assert.IsNull(dmProperty.Class);
            //---------------Execute Test ----------------------
            string actualToString = dmProperty.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual(dmProperty.PropertyName, actualToString);
        }

        [Test]
        public void Test_ToString_ClassIsNull_IDIsNull()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty_WithClassNull();
            dmProperty.PropertyID = null;
            //---------------Assert Precondition----------------
            Assert.IsNull(dmProperty.Class);
            Assert.IsNull(dmProperty.PropertyID);
            //---------------Execute Test ----------------------
            string actualToString = dmProperty.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual(dmProperty.PropertyName, actualToString);
        }

        [Test]
        public void Test_ToString_ClassIsNull_IDIsNull_NameIsNull()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty_WithClassNull();
            dmProperty.PropertyID = null;
            dmProperty.PropertyName = "";
            //---------------Assert Precondition----------------
            Assert.IsNull(dmProperty.Class);
            Assert.IsNull(dmProperty.PropertyID);
            TestUtilsShared.AssertStringEmpty(dmProperty.PropertyName, "dmProperty.PropertyName");
            //---------------Execute Test ----------------------
            string actualToString = dmProperty.ToString();
            //---------------Test Result -----------------------
            Assert.AreEqual("-unnamed DMProperty-", actualToString);
        }

        [Test]
        public void Test_InsertNewDMProperty()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsShared.CreateUnsavedValidDMProperty();

            //---------------Assert Precondition----------------
            Assert.IsTrue(dmProperty.Status.IsNew);

            //---------------Execute Test ----------------------
            dmProperty.Save();

            //---------------Test Result -----------------------
            Assert.IsFalse(dmProperty.Status.IsNew);
        }

        [Test]
        public void Test_InsertNewDMProperty_Invalid()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();

            //---------------Assert Precondition----------------
            Assert.IsTrue(dmProperty.Status.IsNew);

            //---------------Execute Test ----------------------
            try
            {
                dmProperty.Save();
                Assert.Fail("expected Err");
            }
                //---------------Test Result -----------------------
            catch (BusObjectInAnInvalidStateException ex)
            {
                StringAssert.Contains("Class ID' is a compulsory field and has no value", ex.Message);
                StringAssert.Contains("Property Name' is a compulsory field and has no value", ex.Message);
            }
            Assert.IsTrue(dmProperty.Status.IsNew);
        }


        [Test]
        public void TestLink_PropertyNameToMappedDBColumnName()
        {
            //---------------Set up test pack-------------------
            DMProperty newBO = new DMProperty();
            //---------------Execute Test ----------------------
            const string testautocomplete = "TestAutoComplete";
            newBO.PropertyName = testautocomplete;
            //---------------Test Result -----------------------
            Assert.AreEqual(testautocomplete, newBO.MappedDBColumnName);
        }

        [Test]
        public void TestLink_PropertyNameToDisplayName()
        {
            //---------------Set up test pack-------------------
            DMProperty newBO = new DMProperty();
            //---------------Execute Test ----------------------
            const string testautocomplete = "TestAutoComplete";
            newBO.PropertyName = testautocomplete;
            //---------------Test Result -----------------------
            Assert.AreEqual(StringUtilities.DelimitPascalCase(testautocomplete, " "), newBO.DisplayName);
        }

        [Test]
        public void TestLink_ConstructedViaSerialisation_PropertyNameToDisplayName()
        {
            //---------------Set up test pack-------------------
            DMProperty newBO = new DMProperty();
            IFormatter formatter = new BinaryFormatter();
            MemoryStream memoryStream = new MemoryStream();
            formatter.Serialize(memoryStream, newBO);
            memoryStream.Seek(0, SeekOrigin.Begin);
            BusinessObjectManager.Instance.ClearLoadedObjects();
            newBO = (DMProperty) formatter.Deserialize(memoryStream);
            //---------------Assert Precondition----------------
            Assert.IsNull(newBO.DisplayName);
            //---------------Execute Test ----------------------
            const string testautocomplete = "TestAutoComplete";
            newBO.PropertyName = testautocomplete;
            //---------------Test Result -----------------------
            Assert.AreEqual(StringUtilities.DelimitPascalCase(testautocomplete, " "), newBO.DisplayName);
        }

//
//        [Test]
//        public void Test_CreateNewProperty_CreatesDefaultPropRule()
//        {
//            //---------------Set up test pack-------------------
//            
//            //---------------Assert Precondition----------------
//
//            //---------------Execute Test ----------------------
//            DMProperty newProp = new DMProperty();
//            //---------------Test Result -----------------------
//            Assert.IsNotNull(newProp.DefaultPropRule);
////            Assert.AreEqual(1, newProp.PropRules.Count);
//        }

        [Test]
        public void Test_CreateNewProperty_DefaultsToPropertyTypeString()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsDMClass.CreateSavedDMClass();
            //---------------Assert Precondition----------------
            Assert.AreEqual(10, dmClass.Solution.PropertyTypes.Count);
            //---------------Execute Test ----------------------
            DMProperty dmProperty = dmClass.CreateDMProp();
            dmProperty.PropertyName = "A Name";
            //---------------Test Result -----------------------
            Assert.IsNotNull(dmProperty.PropertyName);
            Assert.AreEqual("System.String", dmProperty.PropertyTypeString);
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;
            Assert.IsNotNull(defaultPropRule);
            Assert.AreEqual(dmProperty.PropertyName, defaultPropRule.PropRuleName);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual
                (4, propRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            DMPropRuleParameter parameter = propRuleParameters[0];
            Assert.AreEqual("minLength", parameter.KeyName);
            Assert.AreEqual(1, parameter.OrdinalPosition);
            parameter = propRuleParameters[1];
            Assert.AreEqual("maxLength", parameter.KeyName);
            Assert.AreEqual(2, parameter.OrdinalPosition);
            parameter = propRuleParameters[2];
            Assert.AreEqual("patternMatch", parameter.KeyName);
            Assert.AreEqual(3, parameter.OrdinalPosition);
            parameter = propRuleParameters[3];
            Assert.AreEqual("patternMatchMessage", parameter.KeyName);
            Assert.AreEqual(4, parameter.OrdinalPosition);
        }

        [Test]
        public void Test_PropertyTypeLookupList()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            ClassDef.ClassDefs.Clear();
            ClassDef.ClassDefs.Add(new XmlClassDefsLoader(BOBroker.GetClassDefsXml(), new DtdLoader()).LoadClassDefs());
            TestUtilsShared.CreateSavedPropertyTypeInfo();
            TestUtilsShared.CreateSavedPropertyTypeInfo();
            DMProperty dmProperty = new DMProperty {PropertyName = "A Name"};
            IPropDef propDef = dmProperty.Props["PropertyTypeID"].PropDef;
            //---------------Assert Precondition----------------
            Assert.IsTrue(propDef.HasLookupList());
            //---------------Execute Test ----------------------
            ILookupList lookupList = propDef.LookupList;
            //---------------Test Result -----------------------
            Assert.IsNotNull(lookupList);
            Assert.AreEqual(2, lookupList.GetLookupList().Count);
        }

        [Test]
        public void Test_SetPropertyTypeInt_CreatesCorrectPropRuleParameters()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            dmProperty.PropertyTypeString = "System.String";
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;

            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (4, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_INT32;
            //--------------- Test Result -----------------------
            Assert.AreEqual(DMPropertyType.PROP_TYPE_INT32, dmProperty.PropertyTypeString);
            Assert.AreEqual(dmProperty.PropertyName, defaultPropRule.PropRuleName);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual(2, propRuleParameters.Count);
            DMPropRuleParameter parameter = propRuleParameters[0];
            Assert.AreEqual("min", parameter.KeyName);
            Assert.AreEqual(1, parameter.OrdinalPosition);
            parameter = propRuleParameters[1];
            Assert.AreEqual("max", parameter.KeyName);
            Assert.AreEqual(2, parameter.OrdinalPosition);
        }

        [Test]
        public void Test_SetPropertyTypeDecimal_CreatesCorrectPropRuleParameters()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;

            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (4, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_DECIMAL;
            //--------------- Test Result -----------------------
            Assert.AreEqual(DMPropertyType.PROP_TYPE_DECIMAL, dmProperty.PropertyTypeString);
            Assert.AreEqual(dmProperty.PropertyName, defaultPropRule.PropRuleName);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual(2, propRuleParameters.Count);
            DMPropRuleParameter parameter = propRuleParameters[0];
            Assert.AreEqual("min", parameter.KeyName);
            Assert.AreEqual(1, parameter.OrdinalPosition);
            parameter = propRuleParameters[1];
            Assert.AreEqual("max", parameter.KeyName);
            Assert.AreEqual(2, parameter.OrdinalPosition);
        }

        [Test]
        public void Test_PropertyTypeDateTime_CreatesCorrectPropRuleParameters()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;

            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (4, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_DATETIME;
            //--------------- Test Result -----------------------
            Assert.AreEqual(DMPropertyType.PROP_TYPE_DATETIME, dmProperty.PropertyTypeString);
            Assert.AreEqual(dmProperty.PropertyName, defaultPropRule.PropRuleName);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual(2, propRuleParameters.Count);
            DMPropRuleParameter parameter = propRuleParameters[0];
            Assert.AreEqual("min", parameter.KeyName);
            Assert.AreEqual(1, parameter.OrdinalPosition);
            parameter = propRuleParameters[1];
            Assert.AreEqual("max", parameter.KeyName);
            Assert.AreEqual(2, parameter.OrdinalPosition);
        }

        [Test]
        public void Test_PropertyTypeSingle_CreatesCorrectPropRuleParameters()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;
            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (4, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_SINGLE;
            //--------------- Test Result -----------------------
//            Assert.AreEqual(1, dmProperty.PropRules.Count);
            Assert.AreEqual(DMPropertyType.PROP_TYPE_SINGLE, dmProperty.PropertyTypeString);
            Assert.AreEqual(dmProperty.PropertyName, defaultPropRule.PropRuleName);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual(2, propRuleParameters.Count);
            DMPropRuleParameter parameter = propRuleParameters[0];
            Assert.AreEqual("min", parameter.KeyName);
            Assert.AreEqual(1, parameter.OrdinalPosition);
            parameter = propRuleParameters[1];
            Assert.AreEqual("max", parameter.KeyName);
            Assert.AreEqual(2, parameter.OrdinalPosition);
        }

        [Test]
        public void Test_PropertyTypeDouble_CreatesCorrectPropRuleParameters()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;
            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (4, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_DOUBLE;
            //--------------- Test Result -----------------------
            Assert.AreEqual(DMPropertyType.PROP_TYPE_DOUBLE, dmProperty.PropertyTypeString);
            Assert.AreEqual(dmProperty.PropertyName, defaultPropRule.PropRuleName);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual(2, propRuleParameters.Count);
            DMPropRuleParameter parameter = propRuleParameters[0];
            Assert.AreEqual("min", parameter.KeyName);
            Assert.AreEqual(1, parameter.OrdinalPosition);
            parameter = propRuleParameters[1];
            Assert.AreEqual("max", parameter.KeyName);
            Assert.AreEqual(2, parameter.OrdinalPosition);
        }

        [Test]
        public void Test_PropertyTypeTimespan_CreatesCorrectPropRuleParameters()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;

            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (4, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_TIMESPAN;
            //--------------- Test Result -----------------------
            Assert.AreEqual(DMPropertyType.PROP_TYPE_TIMESPAN, dmProperty.PropertyTypeString);
            Assert.AreEqual(dmProperty.PropertyName, defaultPropRule.PropRuleName);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual(0, propRuleParameters.Count);
        }

        [Test]
        public void Test_SetPropertyTypeInt64_CreatesCorrectPropRuleParameters()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            dmProperty.PropertyTypeString = "System.String";
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;

            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (4, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_INT64;
            //--------------- Test Result -----------------------
            Assert.AreEqual(DMPropertyType.PROP_TYPE_INT64, dmProperty.PropertyTypeString);
            Assert.AreEqual(dmProperty.PropertyName, defaultPropRule.PropRuleName);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual(2, propRuleParameters.Count);
            DMPropRuleParameter parameter = propRuleParameters[0];
            Assert.AreEqual("min", parameter.KeyName);
            Assert.AreEqual(1, parameter.OrdinalPosition);
            parameter = propRuleParameters[1];
            Assert.AreEqual("max", parameter.KeyName);
            Assert.AreEqual(2, parameter.OrdinalPosition);
        }

        [Test]
        public void Test_PropertyTypeGuid_ShouldRemovePropRule()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;

            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (4, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
//            Assert.AreEqual(1, dmProperty.PropRules.Count);
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_GUID;
            //--------------- Test Result -----------------------
            Assert.IsTrue(defaultPropRule.Status.IsDeleted);
            Assert.IsNull(dmProperty.DefaultPropRule);
//            Assert.AreEqual(0, dmProperty.PropRules.Count);
//            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
//            Assert.AreEqual(0, propRuleParameters.Count);
        }

        [Test]
        public void Test_PropertyTypeString_CreatesCorrectPropRuleParameters()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_INT32;

            //--------------- Test Preconditions ----------------
            Assert.AreEqual(2, defaultPropRule.PropRuleParameters.Count);
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_STRING;
            //--------------- Test Result -----------------------
            Assert.AreEqual(dmProperty.PropertyName, defaultPropRule.PropRuleName);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual
                (4, propRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            DMPropRuleParameter parameter = propRuleParameters[0];
            Assert.AreEqual("minLength", parameter.KeyName);
            Assert.AreEqual(1, parameter.OrdinalPosition);
            parameter = propRuleParameters[1];
            Assert.AreEqual("maxLength", parameter.KeyName);
            Assert.AreEqual(2, parameter.OrdinalPosition);
            parameter = propRuleParameters[2];
            Assert.AreEqual("patternMatch", parameter.KeyName);
            Assert.AreEqual(3, parameter.OrdinalPosition);
            parameter = propRuleParameters[3];
            Assert.AreEqual("patternMatchMessage", parameter.KeyName);
            Assert.AreEqual(4, parameter.OrdinalPosition);
        }

        [Test]
        public void Test_PropertyTypeInt_ResetToDecimalDoesNotChangePropRuleParameters()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_INT32;
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters = defaultPropRule.PropRuleParameters;
            DMPropRuleParameter parameter1 = propRuleParameters[0];
            DMPropRuleParameter parameter2 = propRuleParameters[1];
            //--------------- Test Preconditions ----------------
            Assert.AreEqual(2, propRuleParameters.Count);
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_DECIMAL;
            //--------------- Test Result -----------------------
            propRuleParameters = defaultPropRule.PropRuleParameters;
            Assert.AreEqual(2, propRuleParameters.Count);
            Assert.IsTrue(propRuleParameters.Contains(parameter1));
            Assert.IsTrue(propRuleParameters.Contains(parameter2));
        }

        [Test]
        public void Test_NullPropertyTypeId_DoesNotRaisesError_WhenSettingNewPropType()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            dmProperty.PropertyType = null;
            //--------------- Test Preconditions ----------------
            Assert.IsNull(dmProperty.PropertyTypeID);
            //--------------- Execute Test ----------------------
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_DECIMAL;
            //--------------- Test Result -----------------------
            Assert.AreEqual(DMPropertyType.PROP_TYPE_DECIMAL, dmProperty.PropertyTypeString);
            BusinessObjectCollection<DMPropRuleParameter> propRuleParameters =
                dmProperty.DefaultPropRule.PropRuleParameters;
            Assert.AreEqual(2, propRuleParameters.Count);
        }

//        [Test]
//        public void Test_SaveProperty_ShouldNotCreateAdditionalPropertyRule()
//        {
//            //---------------Set up test pack-------------------
//            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(1, dmProperty.PropRules.Count);
//            //---------------Execute Test ----------------------
//            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_INT32;
//            dmProperty.Save();
//            //---------------Test Result -----------------------
//            Assert.AreEqual(DMPropertyType.PROP_TYPE_INT32, dmProperty.PropertyTypeString);
//            Assert.AreEqual(1, dmProperty.PropRules.Count);
//        }

        //[Test]
        //public void Test_ChangePropertyType_NullDefaultRule_DoesNotRaiseError()
        //{
        //    //--------------- Set up test pack ------------------
        //    DMProperty dmProperty = TestUtilsShared.CreateSavedDMProperty();
        //    dmProperty.DefaultPropRule.MarkForDelete();
        //    dmProperty.DefaultPropRule = null;
        //    dmProperty.Save();
        //    //--------------- Test Preconditions ----------------
        //    Assert.IsNull(dmProperty.DefaultPropRule);
        //    //--------------- Execute Test ----------------------
        //    dmProperty.PropertyTypeID = DMPropertyType.PROP_TYPE_INT32;
        //    //--------------- Test Result -----------------------
        //    Assert.AreEqual(DMPropertyType.PROP_TYPE_INT32, dmProperty.PropertyTypeID);
        //} 


        [Ignore("Peter-working - these tests work on LGMIS branch but not here")]
        [Test] 
        public void Test_SaveProperty_WithNewUniqueContraintProperty_ShouldNotThrowError()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            dmProperty.Class.CreateUnsavedUniqueConstraint(new List<DMProperty>{dmProperty});
            //---------------Assert Precondition----------------
            IRelationship relationship = dmProperty.Relationships["DMUniqueConstraintProperties"];
            Assert.AreEqual(InsertParentAction.DoNothing, relationship.RelationshipDef.InsertParentAction);
            Assert.IsTrue(dmProperty.Status.IsValid());
            Assert.AreEqual(1, dmProperty.DMUniqueConstraintProperties.Count);
            DMUniqueConstraintProperty uniqueConstraintProperty = dmProperty.DMUniqueConstraintProperties[0];
            Assert.IsTrue(uniqueConstraintProperty.Status.IsNew);
            //---------------Execute Test ----------------------
            dmProperty.Save();
            //---------------Test Result -----------------------
            Assert.IsTrue(uniqueConstraintProperty.Status.IsNew);
        }

        [Ignore("Peter-working - these tests work on LGMIS branch but not here")]
        [Test]
        public void Test_SaveProperty_WithNewOnwnerProperty_ShouldNotThrowError()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMRelationship relationship = dmProperty.Class.RelatedRelationships.CreateBusinessObject();
            DMRelationshipProperty relationshipProperty = new DMRelationshipProperty();
            relationshipProperty.OwnerProperty = dmProperty;
            relationship.RelationshipProperties.Add();
            //---------------Assert Precondition----------------
            Assert.IsTrue(dmProperty.Status.IsValid());
            Assert.AreEqual(1, dmProperty.RelationshipProperties.Count);
            Assert.AreSame(relationshipProperty, dmProperty.RelationshipProperties.First());
            Assert.IsTrue(relationshipProperty.Status.IsNew);
            //---------------Execute Test ----------------------
            dmProperty.Save();
            //---------------Test Result -----------------------
            Assert.IsTrue(relationshipProperty.Status.IsNew);
        }

        [Ignore("Peter-working - these tests work on LGMIS branch but not here")]
        [Test]
        public void Test_SaveProperty_WithNewRelatedProperty_ShouldNotThrowError()
        {

            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMRelationship relationship = dmProperty.Class.RelatedRelationships.CreateBusinessObject();
            DMRelationshipProperty relationshipProperty = new DMRelationshipProperty();
            relationshipProperty.RelatedProperty = dmProperty;
            relationshipProperty.Relationship = relationship;
            //---------------Assert Precondition----------------
            Assert.IsTrue(dmProperty.Status.IsValid());
            Assert.AreEqual(1, dmProperty.RelationshipProperties.Count);
            Assert.AreSame(relationshipProperty, dmProperty.RelationshipProperties[0]);
            Assert.IsTrue(relationshipProperty.Status.IsNew);
            //---------------Execute Test ----------------------
            dmProperty.Save();
            //---------------Test Result -----------------------
            Assert.IsTrue(relationshipProperty.Status.IsNew);
        }

        [Test]
        public void Test_LookupListTypeString_WhenNone_ShouldRetNone()
        {
            //---------------Set up test pack-------------------
            DMProperty property = new DMProperty();
            IModelProperty modelProperty = property;
            
            //---------------Assert Precondition----------------
            Assert.IsNull(property.LookupList);
            Assert.AreEqual(ModelLookupType.None, modelProperty.LookupListType);
            //---------------Execute Test ----------------------
            var lookupListTypeString = property.LookupListTypeString;
            //---------------Test Result -----------------------
            Assert.AreEqual("None", lookupListTypeString);
        }

        [Test]
        public void Test_LookupListTypeString_WhenBusinessObjectLookupList()
        {
            //---------------Set up test pack-------------------
            DMProperty property = new DMProperty();
            DMLookupListBusinessObject dmLookupListBusinessObject = new DMLookupListBusinessObject();
            property.LookupList = dmLookupListBusinessObject;
            IModelProperty modelProperty = property;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(property.LookupList);
            Assert.AreEqual(ModelLookupType.BusinessObject, modelProperty.LookupListType);
            //---------------Execute Test ----------------------
            var lookupListTypeString = property.LookupListTypeString;
            //---------------Test Result -----------------------
            Assert.AreEqual("BusinessObject", lookupListTypeString);
        }

        [Test]
        public void Test_LookupListTypeString_WhenSimpleLookupList()
        {
            //---------------Set up test pack-------------------
            DMProperty property = new DMProperty();
            DMLookupList dmLookupList = new DMLookupListSimple();
            property.LookupList = dmLookupList;
            IModelProperty modelProperty = property;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(property.LookupList);
            Assert.AreEqual(ModelLookupType.Simple, modelProperty.LookupListType);
            //---------------Execute Test ----------------------
            var lookupListTypeString = property.LookupListTypeString;
            //---------------Test Result -----------------------
            Assert.AreEqual("Simple", lookupListTypeString);
        }

        [Test]
        public void Test_LookupListTypeString_WhenDatabaseLookupList()
        {
            //---------------Set up test pack-------------------
            DMProperty property = new DMProperty();
            DMLookupList dmLookupList = new DMLookupListDatabase();
            property.LookupList = dmLookupList;
            IModelProperty modelProperty = property;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(property.LookupList);
            Assert.AreEqual(ModelLookupType.Database, modelProperty.LookupListType);
            //---------------Execute Test ----------------------
            var lookupListTypeString = property.LookupListTypeString;
            //---------------Test Result -----------------------
            Assert.AreEqual("Database", lookupListTypeString);
        }

        [Test]
        public void Test_LookupListType_NoLookupList()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            ModelLookupType modelLookupType = ((IModelProperty)dmProperty).LookupListType;
            //---------------Test Result -----------------------
            Assert.AreEqual(ModelLookupType.None, modelLookupType);
        }

        [Test]
        public void Test_LookupListType_BusinessObjectLookupList()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            DMLookupListBusinessObject dmLookupListBusinessObject = new DMLookupListBusinessObject();
            dmProperty.LookupList = dmLookupListBusinessObject;

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            ModelLookupType modelLookupType = ((IModelProperty)dmProperty).LookupListType;
            //---------------Test Result -----------------------
            Assert.AreEqual(ModelLookupType.BusinessObject, modelLookupType);
        }

        [Test]
        public void Test_LookupListType_SimpleLookupList()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            DMLookupList dmLookupList = new DMLookupListSimple();
            dmProperty.LookupList = dmLookupList;

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            ModelLookupType modelLookupType = ((IModelProperty)dmProperty).LookupListType;
            //---------------Test Result -----------------------
            Assert.AreEqual(ModelLookupType.Simple, modelLookupType);
        }

        [Test]
        public void Test_LookupListType_DatabaseLookupList()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            DMLookupList dmLookupList = new DMLookupListDatabase();
            dmProperty.LookupList = dmLookupList;

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            ModelLookupType modelLookupType = ((IModelProperty)dmProperty).LookupListType;
            //---------------Test Result -----------------------
            Assert.AreEqual(ModelLookupType.Database, modelLookupType);
        }
        [Ignore("Peter-working - these tests work on LGMIS branch but not here")]
        [Test]
        public void Test_SaveProperty_WithNewUIField_ShouldNotThrowError()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            UIField uiField = new UIField {PropertyName = dmProperty.PropertyName};
            
            //---------------Assert Precondition----------------
            Assert.IsTrue(dmProperty.Status.IsValid());
            Assert.IsTrue(uiField.Status.IsNew);
            //---------------Execute Test ----------------------
            dmProperty.Save();
            //---------------Test Result -----------------------
            Assert.IsTrue(uiField.Status.IsNew);
        }

        [Ignore("Peter-working - these tests work on LGMIS branch but not here")]
        [Test]
        public void Test_SaveProperty_WithNewUIGridColumnInfo_ShouldNotThrowError()
        {

            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            UIView uiView = new UIView();
            uiView.Class = (DMClass) dmProperty.Class;
            UIGridInfo gridInfo = new UIGridInfo();
            gridInfo.UIView = uiView;
            UIGridColumnInfo uiGridColumnInfo = new UIGridColumnInfo { PropertyName = dmProperty.PropertyName };
            uiGridColumnInfo.UIGrid = gridInfo;
            uiGridColumnInfo.UIGridColumnControlTypeID = Guid.NewGuid();
            //---------------Assert Precondition----------------
            Assert.IsTrue(dmProperty.Status.IsValid());
            Assert.IsTrue(uiGridColumnInfo.Status.IsNew);
            //---------------Execute Test ----------------------
            dmProperty.Save();
            //---------------Test Result -----------------------
            Assert.IsTrue(uiGridColumnInfo.Status.IsNew);
        }

       
        [Ignore("This is currently failing - need to figure how to prioritise the saving of objects in a transaction")] //TODO Brett 18 May 2009: Ignored Test - This is currently failing - need to figure how to prioritise the saving of objects in a transaction"]
        [Test]
        public void Test_SaveProperty_WithNewObjectID_ShouldNotThrowError()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMObjectIdentity objectIdentity = dmProperty.Class.CreateObjectIdentity(dmProperty);
            //---------------Assert Precondition----------------
            Assert.IsTrue(dmProperty.Status.IsValid());
            Assert.AreSame(objectIdentity, dmProperty.ObjectIdentity);
            Assert.IsTrue(objectIdentity.Status.IsNew);
            //---------------Execute Test ----------------------
            dmProperty.Save();
            //---------------Test Result -----------------------
            Assert.IsTrue(objectIdentity.Status.IsNew);
        }

        [Test]
        public void Test_PropertyHasDefaultPropRule_WithPropRuleParameters_ShouldSaveDefaultPropRule()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_INT32;
            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (2, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 2 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.Save();
            //--------------- Test Result -----------------------
            Assert.IsNotNull(dmProperty.DefaultPropRule);
        }

        [Test]
        public void Test_PropertyHasDefaultPropRule_WithNoPropRuleParameters_ShouldNotSaveDefaultPropRule()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_GUID;
            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (0, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.Save();
            //--------------- Test Result -----------------------
            Assert.IsNull(dmProperty.DefaultPropRule);
            Assert.IsTrue(defaultPropRule.Status.IsDeleted);
            Assert.IsTrue(defaultPropRule.Status.IsNew);
            BusinessObjectCollection<DMPropRule> propRules = new BusinessObjectCollection<DMPropRule>();
            propRules.LoadAll();
            Assert.AreEqual(0, propRules.Count);
        }


        [Test]
        public void Test_SavedPropertyHasDefaultPropRule_WithNoPropRuleParameters_ShouldNotSaveDefaultPropRule()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = TestUtilsDMProperty.CreateSavedDMProperty();
            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;
            dmProperty.PropertyTypeString = DMPropertyType.PROP_TYPE_GUID;
            //--------------- Test Preconditions ----------------
            Assert.AreEqual
                (0, defaultPropRule.PropRuleParameters.Count,
                 "Should have created a Prop Rule with the 4 parameters required for a string.");
            //--------------- Execute Test ----------------------
            dmProperty.Save();
            //--------------- Test Result -----------------------
            Assert.IsNull(dmProperty.DefaultPropRule);
            Assert.IsTrue(defaultPropRule.Status.IsDeleted);
            Assert.IsTrue(defaultPropRule.Status.IsNew);
            BusinessObjectCollection<DMPropRule> propRules = new BusinessObjectCollection<DMPropRule>();
            propRules.LoadAll();
            Assert.AreEqual(0, propRules.Count);
        }

        [Test]
        public void Test_IsDeletable_ShouldReturnFalse_WhenPartOfUniqueConstraint()
        {
            //--------------- Set up test pack ------------------
            string message;
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            IDMClass dmClass = dmProperty.Class;
            List<DMProperty> properties = new List<DMProperty>();
            properties.Add(dmProperty);
            DMUniqueConstraint uniqueConstraint = dmClass.CreateUnsavedUniqueConstraint(properties);
            //--------------- Test Preconditions ----------------
            Assert.AreEqual(1, dmProperty.DMUniqueConstraintProperties.Count);
            Assert.IsFalse(uniqueConstraint.Status.IsDeleted);
            //--------------- Execute Test ----------------------
            bool isDeletable = dmProperty.IsDeletable(out message);
            //----------Test Result -----------------------
            Assert.IsFalse(isDeletable);
            StringAssert.Contains
                ("The property '" + dmProperty + "' cannot be deleted as it is included in the Unique Constraint",
                 message);
        }

        [Test]
        public void Test_IsDeletable_ShouldReturnTrue_WhenPartOfUniqueConstraintThatIsDeleted()
        {
            //--------------- Set up test pack ------------------
            string message;
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            IDMClass dmClass = dmProperty.Class;
            List<DMProperty> properties = new List<DMProperty>();
            properties.Add(dmProperty);
            DMUniqueConstraint uniqueConstraint = dmClass.CreateUnsavedUniqueConstraint(properties);
            uniqueConstraint.MarkForDelete();
            //--------------- Test Preconditions ----------------
            BusinessObjectCollection<DMUniqueConstraintProperty> collection = dmProperty.DMUniqueConstraintProperties;
            collection.Refresh();
            Assert.AreEqual(0, collection.Count);
            Assert.IsTrue(uniqueConstraint.Status.IsDeleted);
            //--------------- Execute Test ----------------------
            bool isDeletable = dmProperty.IsDeletable(out message);
            //----------Test Result -----------------------
            Assert.IsTrue(isDeletable);
        }

        [Test]
        public void Test_IsDeletable_ShouldReturnTrue_WhenNotPartOfUniqueConstraint()
        {
            //--------------- Set up test pack ------------------
            string message;
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            //--------------- Test Preconditions ----------------
            Assert.AreEqual(0, dmProperty.DMUniqueConstraintProperties.Count);

            //--------------- Execute Test ----------------------
            bool isDeletable = dmProperty.IsDeletable(out message);
            //---------------Test Result -----------------------
            Assert.IsTrue(isDeletable);
            Assert.AreEqual("", message);
        }


        [Test]
        public void Test_IsDeletable_ShouldReturnFalse_WhenHasOwnerProperties()
        {
            //--------------- Set up test pack ------------------
            string message;
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            IDMClass dmClass = dmProperty.Class;
            DMRelationship dmRelationship = TestUtilsShared.CreateUnsavedValidRelationshipInfo(dmClass);
            DMRelationshipProperty dmRelationshipProperty = new DMRelationshipProperty();
            dmRelationshipProperty.Relationship = dmRelationship;
            dmRelationshipProperty.OwnerProperty = dmProperty;
            //--------------- Test Preconditions ----------------
            Assert.AreEqual(1, dmProperty.RelationshipProperties.Count);
            Assert.IsFalse(dmRelationship.Status.IsDeleted);
            //--------------- Execute Test ----------------------
            bool isDeletable = dmProperty.IsDeletable(out message);
            //----------Test Result -----------------------
            Assert.IsFalse(isDeletable);
            StringAssert.Contains
                ("The property '" + dmProperty + "' cannot be deleted as it forms part of the Relationship", message);
        }

        [Test]
        public void Test_IsDeletable_ShouldReturnTrue_WhenHasOwnerProperties_ButRelationshipDeleted()
        {
            //--------------- Set up test pack ------------------
            string message;
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            IDMClass dmClass = dmProperty.Class;
            DMRelationship dmRelationship = TestUtilsShared.CreateUnsavedValidRelationshipInfo(dmClass);
            DMRelationshipProperty dmRelationshipProperty = new DMRelationshipProperty();
            dmRelationshipProperty.Relationship = dmRelationship;
            dmRelationshipProperty.OwnerProperty = dmProperty;
            dmRelationship.MarkForDelete();
            //--------------- Test Preconditions ----------------
            BusinessObjectCollection<DMRelationshipProperty> properties = dmProperty.RelationshipProperties;
            properties.Refresh();
            Assert.AreEqual(0, properties.Count);
            Assert.IsTrue(dmRelationship.Status.IsDeleted);
            //--------------- Execute Test ----------------------
            bool isDeletable = dmProperty.IsDeletable(out message);
            //----------Test Result -----------------------
            Assert.IsTrue(isDeletable);
        }

        [Test]
        public void Test_IsDeletable_ShouldReturnFalse_WhenHasRelatedProperties()
        {
            //--------------- Set up test pack ------------------
            string message;
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            IDMClass dmClass = dmProperty.Class;
            DMRelationship dmRelationship = TestUtilsShared.CreateUnsavedValidRelationshipInfo(dmClass);
            DMRelationshipProperty dmRelationshipProperty = new DMRelationshipProperty();
            dmRelationshipProperty.Relationship = dmRelationship;
            dmRelationshipProperty.RelatedProperty = dmProperty;
            //--------------- Test Preconditions ----------------
            Assert.AreEqual(1, dmProperty.RelationshipProperties.Count);
            Assert.IsFalse(dmRelationship.Status.IsDeleted);
            //--------------- Execute Test ----------------------
            bool isDeletable = dmProperty.IsDeletable(out message);
            //----------Test Result -----------------------
            Assert.IsFalse(isDeletable);
            StringAssert.Contains
                ("The property '" + dmProperty + "' cannot be deleted as it forms part of the Relationship", message);
        }

        [Test]
        public void Test_IsDeletable_ShouldReturnTrue_WhenHasRelatedProperties_ButRelationshipDeleted()
        {
            //--------------- Set up test pack ------------------
            string message;
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            IDMClass dmClass = dmProperty.Class;
            DMRelationship dmRelationship = TestUtilsShared.CreateUnsavedValidRelationshipInfo(dmClass);
            DMRelationshipProperty dmRelationshipProperty = new DMRelationshipProperty();
            dmRelationshipProperty.Relationship = dmRelationship;
            dmRelationshipProperty.RelatedProperty = dmProperty;
            dmRelationship.MarkForDelete();
            //--------------- Test Preconditions ----------------
            BusinessObjectCollection<DMRelationshipProperty> properties = dmProperty.RelationshipProperties;
            properties.Refresh();
            Assert.AreEqual(0, properties.Count);
            Assert.IsTrue(dmRelationship.Status.IsDeleted);
            //--------------- Execute Test ----------------------
            bool isDeletable = dmProperty.IsDeletable(out message);
            //----------Test Result -----------------------
            Assert.IsTrue(isDeletable);
        }

        [Test]
        public void Test_IsDeletable_ShouldReturnFalse_WhenGenerated()
        {
            //--------------- Set up test pack ------------------
            string message;
            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            dmProperty.Generated = true;
            //--------------- Test Preconditions ----------------
            Assert.IsTrue(dmProperty.Generated.Value);
            //--------------- Execute Test ----------------------
            bool isDeletable = dmProperty.IsDeletable(out message);
            //----------Test Result -----------------------
            Assert.IsFalse(isDeletable);
            StringAssert.Contains
                ("The property '" + dmProperty.ToString() + "' cannot be deleted as it has already been exported",
                 message);
        }

        [Test]
        public void Test_PropertyNameProp_IsEditable_ShouldBeTrue_WhenNotGenerated()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = new DMProperty();
            //--------------- Test Preconditions ----------------
            Assert.IsFalse(dmProperty.Generated.GetValueOrDefault());
            //--------------- Execute Test ----------------------
            IBOProp prop = dmProperty.Props["PropertyName"];
            //--------------- Test Result -----------------------
            string message = "";
            Assert.AreEqual("", message);
            Assert.IsTrue(prop.IsEditable(out message));
        }

        [Test]
        public void Test_PropertyNameProp_IsEditable_ShouldBeFalse_WhenGenerated()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = new DMProperty();
            dmProperty.Generated = true;
            //--------------- Test Preconditions ----------------
            Assert.IsTrue(dmProperty.Generated.Value);
            //--------------- Execute Test ----------------------
            IBOProp prop = dmProperty.Props["PropertyName"];
            //--------------- Test Result -----------------------
            string message;
            Assert.IsFalse(prop.IsEditable(out message));
        }


        [Test]
        public void Test_PropertyTypeIDProp_IsEditable_ShouldBeTrue_WhenNotGenerated()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = new DMProperty();
            //--------------- Test Preconditions ----------------
            Assert.IsFalse(dmProperty.Generated.GetValueOrDefault());
            //--------------- Execute Test ----------------------
            IBOProp prop = dmProperty.Props["PropertyTypeID"];
            //--------------- Test Result -----------------------
            string message = "";
            Assert.AreEqual("", message);
            Assert.IsTrue(prop.IsEditable(out message));
        }

        [Test]
        public void Test_PropertyTypeIDProp_IsEditable_ShouldBeFalse_WhenGenerated()
        {
            //--------------- Set up test pack ------------------
            DMProperty dmProperty = new DMProperty();
            dmProperty.Generated = true;
            //--------------- Test Preconditions ----------------
            Assert.IsTrue(dmProperty.Generated.Value);
            //--------------- Execute Test ----------------------
            IBOProp prop = dmProperty.Props["PropertyTypeID"];
            //--------------- Test Result -----------------------
            string message;
            Assert.IsFalse(prop.IsEditable(out message));
        }

        [Test]
        public void Test_IsPartOfSingleRelationship_NoClass()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();

            //---------------Execute Test ----------------------
            bool part = dmProperty.IsPartOfSingleRelationship();
            //---------------Test Result -----------------------
            Assert.IsFalse(part);
            //---------------Tear Down -------------------------          
        }

        [Test]
        public void Test_IsPartOfSingleRelationship_WithClass()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = new DMClass();
            DMProperty dmProperty = dmClass.Properties.CreateBusinessObject();

            //---------------Execute Test ----------------------
            bool part = dmProperty.IsPartOfSingleRelationship();
            //---------------Test Result -----------------------
            Assert.IsFalse(part);
            //---------------Tear Down -------------------------          
        }

        [Test]
        public void Test_IsPartOfSingleRelationship_WithSingleRelationship()
        {
            //---------------Set up test pack-------------------
            const Cardinality cardinality = Cardinality.Single;

            DMClass dmClass = new DMClass();
            DMProperty dmProperty = dmClass.Properties.CreateBusinessObject();

            CreateRelatedClass_RelatedOnOneProperty(dmClass, cardinality, dmProperty);

            //---------------Execute Test ----------------------
            bool part = dmProperty.IsPartOfSingleRelationship();
            //---------------Test Result -----------------------
            Assert.IsTrue(part);
            //---------------Tear Down -------------------------          
        }

        [Test]
        public void Test_IsPartOfSingleRelationship_WithMultipleRelationship()
        {
            //---------------Set up test pack-------------------
            const Cardinality cardinality = Cardinality.Multiple;

            DMClass dmClass = new DMClass();
            DMProperty dmProperty = dmClass.Properties.CreateBusinessObject();

            CreateRelatedClass_RelatedOnOneProperty(dmClass, cardinality, dmProperty);

            //---------------Execute Test ----------------------
            bool part = dmProperty.IsPartOfSingleRelationship();
            //---------------Test Result -----------------------
            Assert.IsFalse(part);
            //---------------Tear Down -------------------------          
        }

        [Test]
        public void Test_IsPartOfSingleRelationship_CompositeRelationship()
        {
            //---------------Set up test pack-------------------
            const Cardinality cardinality = Cardinality.Single;

            DMClass dmClass = new DMClass();
            DMProperty dmProperty = dmClass.Properties.CreateBusinessObject();
            DMProperty dmProperty2 = dmClass.Properties.CreateBusinessObject();

            CreateRelatedClass_RelatedOnTwoProperties(dmClass, cardinality, dmProperty, dmProperty2);

            //---------------Execute Test ----------------------
            bool part = dmProperty2.IsPartOfSingleRelationship();
            //---------------Test Result -----------------------
            Assert.IsTrue(part);
            //---------------Tear Down -------------------------          
        }

        [Test]
        public void Test_EditingPropName_WhenFieldIDNotSet_ShouldChangeMappedDBColumnName()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            const string initialname = "IntitialName";
            dmProperty.PropertyName = initialname;
            //---------------Assert Precondition----------------
            Assert.AreEqual(initialname, dmProperty.MappedDBColumnName);
            Assert.IsNull(dmProperty.MappedDBColumnID);
            //---------------Execute Test ----------------------as
            const string expectedNewFieldName = "AnotherName";
            dmProperty.PropertyName = expectedNewFieldName;
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedNewFieldName, dmProperty.MappedDBColumnName);
        }

        [Test]
        public void Test_HasSetter_DefaultsToTrue()
        {
            //---------------Set up test pack-------------------
            
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            DMProperty dmProperty = new DMProperty();
            //---------------Test Result -----------------------
            Assert.IsTrue(dmProperty.HasSetter);
        }

        [Test]
        public void Test_DMPropertyNameNoSpecialCharsRule_ShouldBeOnBusinessObject()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ReadOnlyCollection<IBusinessObjectRule> rules = BOHelper.GetBusinessObjectRules(dmProperty);
            //---------------Test Result -----------------------
            TestUtilsShared.AssertHasRuleOfType<DMPropertyNameNoSpecialCharsRule>(rules);
        }

        [Test]
        public void Test_DMPropertyNameNotSameAsClassName_ShouldBeOnBusinessObject()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ReadOnlyCollection<IBusinessObjectRule> rules = BOHelper.GetBusinessObjectRules(dmProperty);
            //---------------Test Result -----------------------
            TestUtilsShared.AssertHasRuleOfType<DMPropertyNameNotSameAsClassName>(rules);
        }

        [Test]
        public void Test_DMPropertyNameDoesNotStartWithNumber_ShouldBeOnBusinessObject()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ReadOnlyCollection<IBusinessObjectRule> rules = BOHelper.GetBusinessObjectRules(dmProperty);
            //---------------Test Result -----------------------
            TestUtilsShared.AssertHasRuleOfType<DMPropertyNameDoesNotStartWithNumberRule>(rules);
        }

        [Test]
        public void Test_DMPropertyPropertyTypeSameAsBOLookupListClassIDType_ShouldBeOnBusinessObject()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ReadOnlyCollection<IBusinessObjectRule> rules = BOHelper.GetBusinessObjectRules(dmProperty);
            //---------------Test Result -----------------------
            TestUtilsShared.AssertHasRuleOfType<DMPropertyPropertyTypeSameAsBOLookupListClassIDType>(rules);
        } 
        
        [Test]
        public void Test_DMPropertyNameRule_ShouldBeOnBusinessObject()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ReadOnlyCollection<IBusinessObjectRule> rules = BOHelper.GetBusinessObjectRules(dmProperty);
            //---------------Test Result -----------------------
            TestUtilsShared.AssertHasRuleOfType<DMPropertyNameRule>(rules);
        } 
        
        [Test]
        public void Test_DMPropertyPropertyTypeIntCanBeOnlyAutoincrement_ShouldBeOnBusinessObject()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            ReadOnlyCollection<IBusinessObjectRule> rules = BOHelper.GetBusinessObjectRules(dmProperty);
            //---------------Test Result -----------------------
            TestUtilsShared.AssertHasRuleOfType<DMPropertyAutoIncrementingMustBeOfTypeInt>(rules);
        }

//        [Test]
//        public void Test_DMPropertyAutoIncrementingMustBeOfTypeInt_ShouldBeOnBusinessObject()
//        {
//            //---------------Set up test pack-------------------
//            DMProperty dmProperty = new DMProperty();
//            //---------------Assert Precondition----------------
//            //---------------Execute Test ----------------------
//            ReadOnlyCollection<IBusinessObjectRule> rules = BOHelper.GetBusinessObjectRules(dmProperty);
//            //---------------Test Result -----------------------
//            TestUtilsShared.AssertHasRuleOfType<DMPropertyAutoIncrementingMustBeOfTypeInt>(rules);
//        }

        [Test]
        public void Test_IsPartOfRelationshipToClass_WhenIs_ShouldBeTrue()
        {
            //---------------Set up test pack-------------------
            const Cardinality cardinality = Cardinality.Single;

            DMClass dmClass = new DMClass();
            DMProperty dmProperty = dmClass.Properties.CreateBusinessObject();

            DMClass relatedClass = new DMClass();
            DMProperty dmRelatedProperty = relatedClass.Properties.CreateBusinessObject();

            DMRelationship relationship = dmClass.OwnerRelationships.CreateBusinessObject();
            relationship.Cardinality = cardinality;
            relationship.RelatedClass = relatedClass;
            DMRelationshipProperty relationshipProperty = relationship.RelationshipProperties.CreateBusinessObject();
            relationshipProperty.OwnerProperty = dmProperty;
            relationshipProperty.RelatedProperty = dmRelatedProperty;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var isPartOfRel = dmProperty.IsPartOfRelationshipToClass(relatedClass);
            //---------------Test Result -----------------------
            Assert.IsTrue(isPartOfRel);
        }
        [Test]
        public void Test_IsPartOfRelationshipToClass_WhenNotIs_ShouldBeFalse()
        {
            //---------------Set up test pack-------------------
            const Cardinality cardinality = Cardinality.Single;

            DMClass dmClass = new DMClass();
            DMProperty dmProperty = dmClass.Properties.CreateBusinessObject();

            DMClass relatedClass = new DMClass();
            DMProperty dmRelatedProperty = relatedClass.Properties.CreateBusinessObject();

            DMRelationship relationship = dmClass.OwnerRelationships.CreateBusinessObject();
            relationship.Cardinality = cardinality;
            relationship.RelatedClass = relatedClass;
            DMRelationshipProperty relationshipProperty = relationship.RelationshipProperties.CreateBusinessObject();
            relationshipProperty.OwnerProperty = dmProperty;
            relationshipProperty.RelatedProperty = dmRelatedProperty;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var isPartOfRel = dmProperty.IsPartOfRelationshipToClass(new DMClass());
            //---------------Test Result -----------------------
            Assert.IsFalse(isPartOfRel);
        }
        private static void CreateRelatedClass_RelatedOnOneProperty
            (DMClass dmClass, Cardinality cardinality, DMProperty dmProperty)
        {
            DMClass relatedClass = new DMClass();
            DMProperty dmRelatedProperty = relatedClass.Properties.CreateBusinessObject();

            DMRelationship relationship = dmClass.OwnerRelationships.CreateBusinessObject();
            relationship.Cardinality = cardinality;
            relationship.RelatedClass = relatedClass;
            DMRelationshipProperty relationshipProperty = relationship.RelationshipProperties.CreateBusinessObject();
            relationshipProperty.OwnerProperty = dmProperty;
            relationshipProperty.RelatedProperty = dmRelatedProperty;
        }

        private static void CreateRelatedClass_RelatedOnTwoProperties
            (DMClass dmClass, Cardinality cardinality, DMProperty dmProperty, DMProperty dmProperty2)
        {
            DMClass relatedClass = new DMClass();
            DMProperty dmRelatedProperty = relatedClass.Properties.CreateBusinessObject();
            DMProperty dmRelatedProperty2 = relatedClass.Properties.CreateBusinessObject();

            DMRelationship relationship = dmClass.OwnerRelationships.CreateBusinessObject();
            relationship.Cardinality = cardinality;
            relationship.RelatedClass = relatedClass;
            DMRelationshipProperty relationshipProperty = relationship.RelationshipProperties.CreateBusinessObject();
            relationshipProperty.OwnerProperty = dmProperty;
            relationshipProperty.RelatedProperty = dmRelatedProperty;
            DMRelationshipProperty relationshipProperty2 = relationship.RelationshipProperties.CreateBusinessObject();
            relationshipProperty2.OwnerProperty = dmProperty2;
            relationshipProperty2.RelatedProperty = dmRelatedProperty2;
        }


        [Test]
        public void Test_AreBothPropTypesSame_WhenRelatedPropNull_ShouldBeFalse()
        {
            //---------------Set up test pack-------------------
            DMProperty ownerProp = TestUtilsShared.CreateUnsavedValidDMProperty();


            DMRelationshipProperty relationshipProperty = new DMRelationshipProperty
            {
                Property = ownerProp
            };
            //---------------Assert Precondition----------------
            Assert.AreSame(ownerProp, relationshipProperty.OwnerProperty);
            Assert.IsNull(relationshipProperty.RelatedProperty);

            //---------------Execute Test ----------------------
            var isValid = relationshipProperty.AreBothPropTypesSame();
            //---------------Test Result -----------------------
            Assert.IsFalse(isValid);
        }

        [Test]
        public void Test_AreBothPropTypesSame_WhenOwnerPropNull_ShouldBeFalse()
        {
            //---------------Set up test pack-------------------
            DMProperty relatedProperty = TestUtilsShared.CreateUnsavedValidDMProperty();

            DMRelationshipProperty relationshipProperty = new DMRelationshipProperty
            {
                RelatedProperty = relatedProperty
            };
            //---------------Assert Precondition----------------
            Assert.IsNull(relationshipProperty.OwnerProperty);
            Assert.AreSame(relatedProperty, relationshipProperty.RelatedProperty);

            //---------------Execute Test ----------------------
            var isValid = relationshipProperty.AreBothPropTypesSame();
            //---------------Test Result -----------------------
            Assert.IsFalse(isValid);
        }
        [Test]
        public void Test_AreBothPropTypesSame_WhenPropTypesMatch_ShouldReturnTrue()
        {
            //---------------Set up test pack-------------------
            DMProperty ownerProp = TestUtilsShared.CreateUnsavedValidDMProperty();

            DMProperty relatedProp = TestUtilsShared.CreateUnsavedValidDMProperty();

            DMRelationshipProperty relationshipProperty = new DMRelationshipProperty
            {
                Property = ownerProp,
                RelatedProperty = relatedProp
            };
            //---------------Assert Precondition----------------
            Assert.AreSame(ownerProp, relationshipProperty.OwnerProperty);
            Assert.AreSame(relatedProp, relationshipProperty.RelatedProperty);
            Assert.AreEqual(relatedProp.PropertyTypeString, ownerProp.PropertyTypeString);
            //---------------Execute Test ----------------------
            var isValid = relationshipProperty.AreBothPropTypesSame();
            //---------------Test Result -----------------------
            Assert.IsTrue(isValid);
        }
        [Test]
        public void Test_AreBothPropTypesSame_WhenPropTypesNotMatch_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------

            DMProperty ownerProp = TestUtilsShared.CreateUnsavedValidDMProperty();

            DMProperty relatedProp = TestUtilsShared.CreateUnsavedValidDMProperty();
            relatedProp.PropertyTypeString = "System.Guid";
            DMRelationshipProperty relationshipProperty = new DMRelationshipProperty
            {
                Property = ownerProp,
                RelatedProperty = relatedProp
            };
            //---------------Assert Precondition----------------
            Assert.AreSame(ownerProp, relationshipProperty.OwnerProperty);
            Assert.AreSame(relatedProp, relationshipProperty.RelatedProperty);
            Assert.AreNotEqual(relatedProp.PropertyTypeString, ownerProp.PropertyTypeString);
            //---------------Execute Test ----------------------
            var isValid = relationshipProperty.AreBothPropTypesSame();
            //---------------Test Result -----------------------
            Assert.IsFalse(isValid);
        }
/*                [Test]
        public void Test_SetupRelationship_WhenHasRelatedFK_WhenFKIsUniqueConstraint_ShouldCreateOneToOne()
        {
            //---------------Set up test pack-------------------
            DMClass ownerClass;
            DMClass relatedClass;
            DMRelationshipCreator creator = CreateCreatorWithTwoClasses(out ownerClass, out relatedClass);
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(ownerClass);
            property.PropertyName = relatedClass.ClassNameBO + "ID";
            relatedClass.CreateUnsavedUniqueConstraint(new List<DMProperty> { property });

            DMProperty foundProperty = creator.FindOwnerForeignKeyProp();
            //---------------Assert Precondition----------------
            Assert.IsNotNull(foundProperty);
            Assert.AreSame(property, foundProperty);
                        Assert.AreEqual(1, relatedClass.UniqueConstraints.Count);
            var uniqueConstraint = relatedClass.UniqueConstraints[0];
            Assert.AreEqual(1, uniqueConstraint.UniqueConstraintProperties.Count);
            Assert.AreEqual(1, property.DMUniqueConstraintProperties.Count);
            Assert.AreSame(uniqueConstraint,property.DMUniqueConstraintProperties[0].UniqueConstraint);
            //---------------Execute Test ----------------------
            creator.SetupRelationship();
            //---------------Test Result -----------------------
            Assert.AreEqual(Cardinality.Single ,creator.Relationship.Cardinality);
            Assert.AreEqual(Cardinality.Single ,creator.Relationship.ReverseRelationship.Cardinality);
        }*/
        [Test]
        public void Test_IsPartOfSingleUniqueConstraint_WhenIs_ShouldReturnTrue()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsDMClass.CreateUnsavedDefaultDMClass();
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            dmClass.CreateUnsavedUniqueConstraint(new List<DMProperty> { property });
            //---------------Assert Precondition----------------
            var uniqueConstraint = dmClass.UniqueConstraints[0];
            Assert.AreEqual(1, uniqueConstraint.UniqueConstraintProperties.Count);
            Assert.AreEqual(1, property.DMUniqueConstraintProperties.Count);
            Assert.AreSame(uniqueConstraint, property.DMUniqueConstraintProperties[0].UniqueConstraint);
            //---------------Execute Test ----------------------
            var isPartOfSingleUniqueConstraint = property.IsPartOfSingleUniqueConstraint;
            //---------------Test Result-----------------------
            Assert.IsTrue(isPartOfSingleUniqueConstraint);
        }

        [Test]
        public void Test_IsPartOfSingleUniqueContraints_WhenNotOnAnyUC_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsDMClass.CreateUnsavedDefaultDMClass();
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, property.DMUniqueConstraintProperties.Count);
            
            //---------------Execute Test ----------------------
            var isPartOfSingleUniqueConstraint = property.IsPartOfSingleUniqueConstraint;
            //---------------Test Result -----------------------
            Assert.IsFalse(isPartOfSingleUniqueConstraint);

        }
        [Test]
        public void Test_IsPartOfSingleUniqueContraints_WhenCompositeUC_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsDMClass.CreateUnsavedDefaultDMClass();
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            DMProperty property2 = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            var uniqueConstraint = dmClass.CreateUnsavedUniqueConstraint(new List<DMProperty> { property,property2 });
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, uniqueConstraint.UniqueConstraintProperties.Count);
            Assert.AreEqual(1, property.DMUniqueConstraintProperties.Count);
            //---------------Execute Test ----------------------
            var isPartOfSingleUniqueConstraint = property.IsPartOfSingleUniqueConstraint;
            //---------------Test Result -----------------------
            Assert.IsFalse(isPartOfSingleUniqueConstraint);

        }
        [Test]
        public void Test_IsPartOfSingleUniqueContraints_InTwoCompositeUCs_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsDMClass.CreateUnsavedDefaultDMClass();
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            DMUniqueConstraint uniqueConstraint = CreateCompositeUniqueConstraint(dmClass, property);
            DMUniqueConstraint uniqueConstraint2 = CreateCompositeUniqueConstraint(dmClass, property);
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, uniqueConstraint.UniqueConstraintProperties.Count);
            Assert.AreEqual(2, uniqueConstraint2.UniqueConstraintProperties.Count);
            Assert.AreEqual(2, property.DMUniqueConstraintProperties.Count);
            //---------------Execute Test ----------------------
            var isPartOfSingleUniqueConstraint = property.IsPartOfSingleUniqueConstraint;
            //---------------Test Result -----------------------
            Assert.IsFalse(isPartOfSingleUniqueConstraint);
        }
        [Test]
        public void Test_IsPartOfSingleUniqueContraints_InOneCompUC_OneSingleUC_ShouldReturnTrue()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsDMClass.CreateUnsavedDefaultDMClass();
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            DMUniqueConstraint uniqueConstraint = CreateCompositeUniqueConstraint(dmClass, property);
            var singleUc = dmClass.CreateUnsavedUniqueConstraint(new List<DMProperty> { property });
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, uniqueConstraint.UniqueConstraintProperties.Count);
            Assert.AreEqual(1, singleUc.UniqueConstraintProperties.Count);
            Assert.AreEqual(2, property.DMUniqueConstraintProperties.Count);
            //---------------Execute Test ----------------------
            var isPartOfSingleUniqueConstraint = property.IsPartOfSingleUniqueConstraint;
            //---------------Test Result -----------------------
            Assert.IsTrue(isPartOfSingleUniqueConstraint);
        }

        [Test]
        public void Test_IPropDef_PropertyType_ShouldReturnUnderlyingType()
        {
            //---------------Set up test pack-------------------
            const string assemblyName = "System";
            const string typeName = "String";
            var propertyType = new DMPropertyType();
            propertyType.AssemblyName = assemblyName;
            propertyType.PropertyTypeName = typeName;

            DMClass dmClass = TestUtilsDMClass.CreateUnsavedDefaultDMClass();
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            property.PropertyType = propertyType;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(property.PropertyType);
            //---------------Execute Test ----------------------
            Type underlying = ((IPropDef)property).PropertyType;
            //---------------Test Result -----------------------
            Assert.AreSame(typeof(string), underlying);
        }

        [Test]
        public void Test_GetParent()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = new DMClass();
            DMProperty dmProperty = new DMProperty();
            dmClass.Properties.Add(dmProperty);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            IModelElement parent = ((IModelProperty)dmProperty).Parent;
            //---------------Test Result -----------------------
            Assert.AreSame(dmClass, parent);
        }


        [Test]
        public void Test_SetDMClass_ShouldCreateDefaultRule()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsShared.CreateUnsavedValidDMClass();
            DMProperty dmProperty = new DMProperty();

            //---------------Assert Precondition----------------
            Assert.IsNull(dmProperty.DefaultPropRule);
            //---------------Execute Test ----------------------

            dmProperty.Class = dmClass;
            //---------------Test Result -----------------------
            Assert.IsNotNull(dmProperty.DefaultPropRule);
        }

        [Test]
        public void Test_SetDMPropName_ShouldSetDefaultPropRuleName()
        {
            //---------------Set up test pack-------------------
            DMClass dmClass = TestUtilsShared.CreateUnsavedValidDMClass();
            DMProperty dmProperty = new DMProperty();
            dmProperty.Class = dmClass;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(dmProperty.DefaultPropRule);
            Assert.IsNull(dmProperty.DefaultPropRule.PropRuleName);
            //---------------Execute Test ----------------------
            dmProperty.PropertyName = TestUtilsShared.GetRandomString();
            //---------------Test Result -----------------------
            Assert.IsNotNull(dmProperty.DefaultPropRule);
            Assert.AreEqual(dmProperty.PropertyName, dmProperty.DefaultPropRule.PropRuleName);
            Assert.IsNotNull(dmProperty.DefaultPropRule);
            Assert.IsNotNull(dmProperty.DefaultPropRule.PropRuleName);
        }

        [Test]
        public void Test_SetParentExceptionThrown()
        {
            //---------------Set up test pack-------------------
            IModelProperty modelProperty = new DMProperty();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            Exception exceptionThrown = null;
            try
            {
                modelProperty.Parent = new DMClass();
            }
            catch (Exception ex)
            {
                exceptionThrown = ex;
            }
            //---------------Test Result -----------------------
            Assert.IsNotNull(exceptionThrown);
            Assert.IsInstanceOf(typeof(HabaneroDeveloperException), exceptionThrown);
            StringAssert.Contains
                ("Set the parent of the Property by setting the related Class object", exceptionThrown.Message);
        }

        [Test]
        public void Test_GetPropertyName()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            string propertyName = GetRandomString();
            dmProperty.PropertyName = propertyName;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string name = ((IModelProperty)dmProperty).PropertyName;
            //---------------Test Result -----------------------
            Assert.AreEqual(propertyName, name);
        }

        [Test]
        public void Test_SetPropertyName()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            string propertyName = GetRandomString();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            ((IModelProperty)dmProperty).PropertyName = propertyName;
            //---------------Test Result -----------------------
            Assert.AreEqual(propertyName, dmProperty.PropertyName);
        }

        [Test]
        public void Test_PropertyTypeString()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            DMPropertyType dmPropertyType = new DMPropertyType();
            string assemblyName = GetRandomString();
            dmPropertyType.AssemblyName = assemblyName;
            string propertyTypeName = GetRandomString();
            dmPropertyType.PropertyTypeName = propertyTypeName;
            dmProperty.PropertyType = dmPropertyType;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string name = ((IModelProperty)dmProperty).PropertyTypeString;
            //---------------Test Result -----------------------
            Assert.AreEqual(assemblyName + "." + propertyTypeName, name);
        }

        private string GetRandomString()
        {
            return TestUtilsShared.GetRandomString();
        }

#pragma warning disable 168
        [Test]
        public void Test_PropertyTypeString_NullPropertyType_ThrowsException()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            Exception exceptionThrown = null;
            try
            {
                string name = ((IModelProperty)dmProperty).PropertyTypeString;
            }
            catch (Exception ex)
            {
                exceptionThrown = ex;
            }
            //---------------Test Result -----------------------
            Assert.IsNotNull(exceptionThrown);
            Assert.IsInstanceOf(typeof(HabaneroDeveloperException), exceptionThrown);
            Assert.AreEqual
                (string.Format("The property type for the property '{0}' has not been set.", dmProperty.PropertyName),
                 exceptionThrown.Message);
        }
#pragma warning restore 168
        [Test]
        public void Test_HasSetter()
        {
            //---------------Set up test pack-------------------
            IModelProperty dmProperty = new DMProperty();
            dmProperty.HasSetter = true;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            bool hasSetter = dmProperty.HasSetter;
            //---------------Test Result -----------------------
            Assert.IsTrue(hasSetter);
        }

        [Test]
        public void Test_DefaultValue()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            string defaultValue = GetRandomString();
            dmProperty.DefaultValue = defaultValue;
            //---------------Assert Precondition----------------

            //---------------Execute Test --------------------
            string testDefaultValue = ((IModelProperty)dmProperty).DefaultValue;

            //---------------Test Result -----------------------
            Assert.AreEqual(defaultValue, testDefaultValue);
        }

        [Test]
        public void Test_IsCompulsory()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            dmProperty.Compulsory = true;
            //---------------Assert Precondition----------------

            //---------------Execute Test --------------------
            bool isCompulsory = ((IModelProperty)dmProperty).IsCompulsory;

            //---------------Test Result -----------------------
            Assert.IsTrue(isCompulsory);
        }

        [Test]
        public void Test_PropertyType()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            DMPropertyType dmPropertyType = new DMPropertyType();
            dmPropertyType.PropertyTypeName = "String";
            dmProperty.PropertyType = dmPropertyType;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            IModelPropertyType propertyType = ((IModelProperty)dmProperty).PropertyType;
            //---------------Test Result -----------------------
            Assert.AreSame(dmPropertyType, propertyType);
        }

        [Test]
        public void Test_ReadWriteRule()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            dmProperty.ReadWriteRule = PropReadWriteRule.WriteNew;

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string readWriteRule = ((IModelProperty)dmProperty).ReadWriteRule;
            //---------------Test Result -----------------------
            Assert.AreSame(PropReadWriteRule.WriteNew.ToString(), readWriteRule);
        }
#pragma warning disable 168
        [Test]
        public void Test_ReadWriteRule_NullValue_ThrowsException()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProperty = new DMProperty();
            dmProperty.ReadWriteRule = null;

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            Exception exceptionThrown = null;
            try
            {
                string readWriteRule = ((IModelProperty)dmProperty).ReadWriteRule;
            }
            catch (Exception ex)
            {
                exceptionThrown = ex;
            }
            //---------------Test Result -----------------------
            Assert.IsNotNull(exceptionThrown);
            Assert.IsInstanceOf(typeof(HabaneroDeveloperException), exceptionThrown);
            Assert.AreEqual
                (string.Format("ReadWriteRule has a null value for the property '{0}'", dmProperty.PropertyName),
                 exceptionThrown.Message);
        }
#pragma warning restore 168
        //        [Test]
        //        public void Test_Max_NoRule()
        //        {
        //            //---------------Set up test pack-------------------
        //            DMProperty dmProperty = TestUtilsDMProperty.CreateSavedDMProperty();
        //            dmProperty.PropertyTypeString = "System.String";
        //            //---------------Assert Precondition----------------
        //            Assert.AreEqual
        //                ("System.String", dmProperty.PropertyTypeString,
        //                 "This is messed up, and you can fix this test when you fix the messed up property types");
        ////            Assert.AreEqual(1, dmProperty.PropRules.Count);
        ////            DMPropRuleParameter defaultMaxLengthParameter = dmProperty.PropRules[0].PropRuleParameters[1];
        //            Assert.AreEqual("maxLength", defaultMaxLengthParameter.KeyName);
        //            Assert.IsNull(defaultMaxLengthParameter.Value);
        //            //---------------Execute Test ----------------------
        //            string max = ((IModelProperty) dmProperty).Max;
        //            //---------------Test Result -----------------------
        //            Assert.AreEqual("", max);
        //        }

        [Test]
        public void Test_Max_EditDefaultRule()
        {
            //---------------Set up test pack-------------------
            const int maxValue = int.MaxValue - 100;
            DMProperty dmProperty = TestUtilsDMProperty.CreateSavedDMProperty();
            dmProperty.PropertyTypeString = "System.Int32";
            dmProperty.DefaultPropRule.PropRuleParameters[1].Value = maxValue.ToString();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string max = ((IModelProperty)dmProperty).Max;
            //---------------Test Result -----------------------
            Assert.AreEqual(maxValue.ToString(), max);
        }

        [Test]
        public void Test_SetPropertyTypeString_ShouldSetCorrectPropertyType()
        {
            //            //---------------Set up test pack-------------------
            //            DMSolution solution = TestUtilsDMSolution.
            //            DMProperty dmProperty = new DMProperty();
            //            //---------------Assert Precondition----------------
            //
            //            //---------------Execute Test ----------------------
            //            dmProperty.PropertyTypeString ="System.Int32";
            //            //---------------Test Result -----------------------
        }

        [Test]
        public void Test_RenameProp_WhenMappedColumnNull_ShouldRenameDBAndDisplayNameToStandardName()
        {
            //---------------Set up test pack-------------------
            DMProperty dmProp = new DMProperty
            {
                PropertyName = GetRandomString(),
                DisplayName = GetRandomString(),
                MappedDBColumnName = GetRandomString()
            };
            //---------------Assert Precondition----------------
            Assert.IsNull(dmProp.MappedDBColumn);
            Assert.AreNotEqual(DMProperty.GetColumnNameFromPropName(dmProp.PropertyName), dmProp.MappedDBColumnName);
            Assert.AreNotEqual(DMProperty.GetDisplayNameFromPropertyName(dmProp.PropertyName), dmProp.DisplayName);
            //---------------Execute Test ----------------------
            dmProp.RenameProperty();
            //---------------Test Result -----------------------
            Assert.AreEqual(DMProperty.GetColumnNameFromPropName(dmProp.PropertyName), dmProp.MappedDBColumnName);
            Assert.AreEqual(DMProperty.GetDisplayNameFromPropertyName(dmProp.PropertyName), dmProp.DisplayName);
        }


        [Ignore(" TODO Temp commented out")] //TODO Brett 02 Apr 2009:
        [Test]
        public void Test_Max_Int()
        {
            Assert.Fail();
            //TODO 2009-03-09 Eric - when you change the property type, the default rules should change, like in the old Firestarter
            //
            //            //---------------Set up test pack-------------------
            //            const int maxValue = int.MaxValue - 100;
            //            DMProperty dmProperty = new DMProperty();
            //            dmProperty.PropertyTypeID = "System.Int32"; //fix this
            //
            //            DMPropRule defaultPropRule = dmProperty.PropRules[0];
            //            dmProperty.PropRules.Remove(defaultPropRule);
            //            dmProperty.DefaultPropRule = null;
            //
            //            //---------------Assert Precondition----------------
            //            Assert.AreEqual(0, dmProperty.PropRules.Count);
            //            Assert.IsNull(dmProperty.DefaultPropRule);
            //
            //            //---------------Set up test pack-------------------
            //            DMPropRule dmPropRule = new DMPropRule();
            //            DMPropRuleParameter propRuleParameter = new DMPropRuleParameter();
            //            propRuleParameter.KeyName = "max";
            //            propRuleParameter.Value = maxValue.ToString();
            //            propRuleParameter.PropRule = dmPropRule;
            //            dmPropRule.Property = dmProperty;
            //            //---------------Assert Precondition----------------
            //            Assert.AreEqual("System.Int32", dmProperty.PropertyTypeID, "Fix me");
            //            Assert.AreEqual(1, dmProperty.PropRules.Count);
            //            //---------------Execute Test ----------------------
            //            string max = ((IModelProperty)dmProperty).Max;
            //            //---------------Test Result -----------------------
            //            Assert.AreEqual(maxValue.ToString(), max);
        }

        //        [Test,
        //         Ignore(
        //             "This is a fairly trivial case, get it done when there's time - basically, if you have multiple max's, must take the minimum of them, make similar rule for min"
        //             )]
        //        public void Test_Max_MultipleRulesGetsMinimumLength()
        //        {
        //            //---------------Set up test pack-------------------
        //            string biggerMaxValue = (int.MaxValue - 100).ToString();
        //            string smallerMaxValue = (int.MaxValue - 110).ToString();
        //
        //            DMProperty dmProperty = new DMProperty();
        //
        //            DMPropRule dmPropRule = new DMPropRule();
        //            DMPropRuleParameter propRuleParameter = new DMPropRuleParameter();
        //            propRuleParameter.KeyName = "maxLength";
        //            propRuleParameter.Value = smallerMaxValue;
        //            propRuleParameter.PropRule = dmPropRule;
        //            dmPropRule.Property = dmProperty;
        //
        //            //---------------Assert Precondition----------------
        //            Assert.AreEqual
        //                ("System.String", dmProperty.PropertyTypeID,
        //                 "This is messed up, and you can fix this test when you fix the messed up property types");
        ////            Assert.AreEqual(2, dmProperty.PropRules.Count);
        ////            DMPropRuleParameter defaultMaxLengthParameter = dmProperty.PropRules[0].PropRuleParameters[1];
        ////            Assert.AreEqual("maxLength", defaultMaxLengthParameter.KeyName);
        //            //---------------Execute Test ----------------------
        //            dmProperty.PropRules[0].PropRuleParameters[1].Value = biggerMaxValue;
        //            string max = ((IModelProperty) dmProperty).Max;
        //            //---------------Test Result -----------------------
        //            Assert.AreEqual(smallerMaxValue, max);
        //        }

        //        [Test] //This test ensures that the foreach is working to find the rule at deeper levels
        //        public void Test_Max_NewRule_WithNonDefaultParameterName()
        //        {
        //            //---------------Set up test pack-------------------
        //            DMProperty dmProperty = new DMProperty();
        //            DMPropRule defaultPropRule = dmProperty.DefaultPropRule;
        //            dmProperty.DefaultPropRule = null;
        //
        //            //---------------Assert Precondition----------------
        ////            Assert.AreEqual(0, dmProperty.PropRules.Count);
        //            Assert.IsNull(dmProperty.DefaultPropRule);
        //
        //            //---------------Set up test pack-------------------
        //            DMPropRule emptyPropRule = new DMPropRule();
        //            dmProperty.DefaultPropRule = emptyPropRule;
        //
        //            DMPropRule dmPropRule = new DMPropRule();
        //            DMPropRuleParameter propRuleParameter = new DMPropRuleParameter();
        //            const string ruleParamName = "maxLength";
        //            propRuleParameter.KeyName = ruleParamName;
        //            const string expectedValue = "passValue";
        //            propRuleParameter.Value = expectedValue;
        //            propRuleParameter.PropRule = dmPropRule;
        //            dmProperty.PropRules.Add(dmPropRule);
        //
        //            //---------------Assert Precondition----------------
        //            Assert.AreEqual(2, dmProperty.PropRules.Count);
        //            Assert.AreEqual(0, emptyPropRule.PropRuleParameters.Count);
        //            Assert.AreEqual(ruleParamName, dmProperty.PropRules[1].PropRuleParameters[0].KeyName);
        //            //---------------Execute Test ----------------------
        //            string max = ((IModelProperty) dmProperty).Max;
        //            //---------------Test Result -----------------------
        //            Assert.AreEqual(expectedValue, max);
        //        }

        //        [Test]
        //        public void Test_Min_NoRule()
        //        {
        //            //---------------Set up test pack-------------------
        //            DMProperty dmProperty = TestUtilsDMProperty.CreateSavedDMProperty();
        //            dmProperty.PropertyTypeString = "System.String";
        //            //---------------Assert Precondition----------------
        //            Assert.AreEqual
        //                ("System.String", dmProperty.PropertyTypeString,
        //                 "This is messed up, and you can fix this test when you fix the messed up property types");
        //            Assert.AreEqual(1, dmProperty.PropRules.Count);
        //            DMPropRuleParameter defaultMaxLengthParameter = dmProperty.PropRules[0].PropRuleParameters[0];
        //            Assert.AreEqual("minLength", defaultMaxLengthParameter.KeyName);
        //            Assert.IsNull(defaultMaxLengthParameter.Value);
        //            //---------------Execute Test ----------------------
        //            string min = ((IModelProperty) dmProperty).Min;
        //            //---------------Test Result -----------------------
        //            Assert.AreEqual("", min);
        //        }

        //        [Test]
        //        public void Test_MinLength_ForString_ShouldSetMinLength()
        //        {
        //            //---------------Set up test pack-------------------
        //            const int minValue = 0 + 100;
        //            DMProperty dmProperty = TestUtilsDMProperty.CreateSavedDMProperty();
        //            dmProperty.PropertyTypeString = "System.Int32";
        //            dmProperty.PropRules[0].PropRuleParameters[0].Value = minValue.ToString();
        //            //---------------Assert Precondition----------------
        //
        //            //---------------Execute Test ----------------------
        //            string min = ((IModelProperty) dmProperty).Min;
        //            //---------------Test Result -----------------------
        //            Assert.AreEqual(minValue.ToString(), min);
        //        }

        //        [Test]
        //        public void Test_Min_Int()
        //        {
        //            //---------------Set up test pack-------------------
        //            const int minValue = int.MinValue + 100;
        //            DMProperty dmProperty = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
        //            dmProperty.PropertyTypeString = "System.Int32";
        //
        //            DMPropRule defaultPropRule = dmProperty.PropRules[0];
        //            dmProperty.PropRules.Remove(defaultPropRule);
        //            dmProperty.DefaultPropRule = null;
        //
        //            //---------------Assert Precondition----------------
        //            Assert.AreEqual(0, dmProperty.PropRules.Count);
        //            Assert.IsNull(dmProperty.DefaultPropRule);
        //
        //            //---------------Set up test pack-------------------
        //            DMPropRule dmPropRule = new DMPropRule();
        //            DMPropRuleParameter propRuleParameter = new DMPropRuleParameter();
        //            propRuleParameter.KeyName = "min";
        //            propRuleParameter.Value = minValue.ToString();
        //            propRuleParameter.PropRule = dmPropRule;
        //            dmPropRule.Property = dmProperty;
        //            //---------------Assert Precondition----------------
        //            Assert.AreEqual("System.Int32", dmProperty.PropertyTypeString);
        //            Assert.AreEqual(1, dmProperty.PropRules.Count);
        //            //---------------Execute Test ----------------------
        //            string min = ((IModelProperty) dmProperty).Min;
        //            //---------------Test Result -----------------------
        //            Assert.AreEqual(minValue.ToString(), min);
        //        }
        [Test]
        public void Test_ClassName_WhenHasDMClass_ShouldReturnDMClassName()
        {
            //---------------Set up test pack-------------------
            DMProperty property = new DMProperty();
            string expectedClassName = GetRandomString();
            var dmClass = new DMClass();
            dmClass.ClassNameBO = expectedClassName;
            property.Class = dmClass;
            //---------------Assert Precondition----------------
            Assert.AreSame(dmClass, property.Class);
            Assert.IsNotNullOrEmpty(dmClass.ClassNameBO);
            //---------------Execute Test ----------------------
            string className = property.ClassName;
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedClassName, className);
        }  
        [Test]
        public void Test_ClassName_WhenNotHasDMClass_ShouldReturnEmptyString()
        {
            //---------------Set up test pack-------------------
            DMProperty property = new DMProperty();
            //---------------Assert Precondition----------------
            Assert.IsNull(property.Class);
            //---------------Execute Test ----------------------
            string className = property.ClassName;
            //---------------Test Result -----------------------
            Assert.AreEqual("", className);
        }

        [Test]
        public void Test_Solution_WhenDMClassNull_ShouldRetNull()
        {
            //---------------Set up test pack-------------------
            DMProperty property = new DMProperty();
            //---------------Assert Precondition----------------
            Assert.IsNull(property.Class);
            //---------------Execute Test ----------------------
            var solution = property.Solution;
            //---------------Test Result -----------------------
            Assert.IsNull(solution);
        }
        [Test]
        public void Test_Solution_WhenHasDMClass_ShouldRetDMClass()
        {
            //---------------Set up test pack-------------------
            DMProperty property = TestUtilsDMProperty.CreateUnsavedValidDMProperty();
            //---------------Assert Precondition----------------
            Assert.IsNotNull(property.Class);
            Assert.IsNotNull(property.Class.Solution);
            //---------------Execute Test ----------------------
            var solution = property.Solution;
            //---------------Test Result -----------------------
            Assert.IsNotNull(solution);
            Assert.AreSame(property.Class.Solution, solution);
        }

        private static DMUniqueConstraint CreateCompositeUniqueConstraint(IDMClass dmClass, DMProperty property)
        {
            DMProperty property2 = TestUtilsDMProperty.CreateUnsavedValidDMProperty(dmClass);
            DMUniqueConstraint uniqueConstraint = dmClass.CreateUnsavedUniqueConstraint(new List<DMProperty> { property,property2 });
            return uniqueConstraint;
        }
    }
}
